package com.gzmu.storage.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.plugins.Page;
import com.gzmu.storage.entity.Adminlog;
import com.gzmu.storage.mapper.AdminlogMapper;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaobo Yan
 * @since 2020-04-16
 */
@Controller
@RequestMapping("/adminlog")
public class AdminlogController {
    @Autowired
    private AdminlogMapper adminlogMapper;

    @ResponseBody
    @RequestMapping("getAdminlog")
    public Object getAdminlog(int page, int limit){
        Map map = new HashMap<>();
        RowBounds rowBounds = new RowBounds( (page - 1) * limit, limit );
        List<Adminlog> adminlogs = adminlogMapper.selectPage( rowBounds, null);
        int count = adminlogMapper.selectCount( null );
        map.put( "code", 0);
        map.put( "count", count);
        map.put( "data", adminlogs );
        return JSONObject.toJSON(map);
    }
}

